home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / Vk / VkCmd.z / VkCmd
Encoding:
Text File  |  2002-10-03  |  5.6 KB  |  199 lines

  1.  
  2.  
  3.  
  4. VVVVkkkkCCCCmmmmdddd((((3333xxxx))))                                                            VVVVkkkkCCCCmmmmdddd((((3333xxxx))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      VkCmd - the simplest command class
  10.  
  11. IIIINNNNHHHHEEEERRRRIIIITTTTSSSS FFFFRRRROOOOMMMM
  12.      VkBase
  13.  
  14. HHHHEEEEAAAADDDDEEEERRRR FFFFIIIILLLLEEEE
  15.      #include <Vk/VkCmd.h>
  16.  
  17. CCCCLLLLAAAASSSSSSSS DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  18.           VkCmd is the simplest element in the set of ViewKit objects that
  19.           support undoable commands. VkCmd can be subclassed to support
  20.           commands that can be executed directly, or via a VkCmdManager
  21.           object. Subclasses can override the doit() method to define how a
  22.           command should be performed, and undoit() to define how it should be
  23.           reversed. An optional redoit() method allows commands that need to
  24.           perform an action differently if the command is repeated to do so.
  25.           If not defined, this method defaults to calling doit().
  26.  
  27.           In the simplest usage, applications would subclass VkCmd to define
  28.           doit() and undoit(), instantiate a Cmd object and call doit(), or
  29.           undoit() as desired:
  30.  
  31.  
  32.               VkCmd *cmd = new MyCmd();
  33.               cmd->doit();
  34.  
  35.  
  36.  
  37.  
  38. UUUUNNNNDDDDOOOO SSSSUUUUPPPPPPPPOOOORRRRTTTT
  39.           The main benefit of Cmd objects comes from the ability to undo
  40.           commands. VkCmd can be used with the VkCmdManager to achieve this.
  41.           One can ask the VkCmdManager to execute a cmd object:
  42.  
  43.  
  44.               VkCmdManager *cmdManager = new VkCmdManager();
  45.  
  46.               cmdManager->run(new MyCmd());
  47.  
  48.  
  49.           This places the cmd on an undo history list, if the cmd can be
  50.           undone. Whether a command can be undone depends on the return value
  51.           of the doit() method, which must be one of:
  52.  
  53.               VkCmdUndoable:
  54.  
  55.                   The cmd is undoable, and is added to the undo stack. if any
  56.                   cmds are currently available for redo, the VkCmdManager
  57.                   flushes them.
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. VVVVkkkkCCCCmmmmdddd((((3333xxxx))))                                                            VVVVkkkkCCCCmmmmdddd((((3333xxxx))))
  71.  
  72.  
  73.  
  74.               VkCmdNotUndoable:
  75.  
  76.                   This cmd is not undoable. The VkCmdManager flushes all cmds
  77.                   on the undo and redo stack.
  78.  
  79.               VkCmdTransparent:
  80.  
  81.                   The command does not affect the undo/redo stack.
  82.  
  83.           When used in conjunction with the VkCmdManager and VkMenu
  84.           addUndoAction() and addRedoAction() methods, a VkCmd object should
  85.           override the getLabel() method, to supply a label to appear in the
  86.           Undo and Redo menu commands.
  87.  
  88.  
  89. CCCCOOOOMMMMMMMMAAAANNNNDDDD RRRREEEEGGGGIIIISSSSTTTTRRRRYYYY
  90.           Commands can also be executed by name, provided the command
  91.           registers itself with the VkCmdRegistry, a globally available list
  92.           that links unique names to a mechanism for creating command objects.
  93.           Once registered, a command can be invoked by the VkCmdManager by
  94.           name:
  95.  
  96.  
  97.  
  98.              cmdManager->run("CutCommand");
  99.  
  100.  
  101.           To participate in this scheme, commands must register themselves.
  102.           This is made easy by two macros. The class record should include the
  103.           line:
  104.  
  105.  
  106.  
  107.              VK_CMD_DECLARE;
  108.  
  109.  
  110.           in the public portion of the class record, and also include the
  111.           line:
  112.  
  113.  
  114.  
  115.              VK_CMD_IMPLEMENT(ClassName, "ClassName");
  116.  
  117.  
  118.           somewhere in the source file. The first argument is the class name,
  119.           while the second is a unique identifier for this command, which is
  120.           usually the class name as well.
  121.  
  122.           Before the first time the class is used, the program must call:
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. VVVVkkkkCCCCmmmmdddd((((3333xxxx))))                                                            VVVVkkkkCCCCmmmmdddd((((3333xxxx))))
  137.  
  138.  
  139.  
  140.  
  141.  
  142.              ClassName::initClass();
  143.  
  144.  
  145.           where ClassName is the same of the class. In the future, the should
  146.           be a class that is able to extract and invoke the initClass() method
  147.           from a DSO, allowing for "plugin" commands.
  148.  
  149.  
  150.  
  151. SSSSAAAAMMMMPPPPLLLLEEEE CCCCOOOODDDDEEEE
  152.      /usr/share/src/ViewKit/Commands/ByName/
  153.      /usr/share/src/ViewKit/Commands/Factories/
  154.      /usr/share/src/ViewKit/Commands/Factory2/
  155.      /usr/share/src/ViewKit/Commands/Simple/
  156.      /usr/share/src/ViewKit/Commands/Undo/
  157.  
  158.  
  159.  
  160. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  161.      VkCmdManager, VkCmdRegistry, VkCmdFactory
  162.      _V_i_e_w_K_i_t _P_r_o_g_r_a_m_m_e_r'_s _G_u_i_d_e
  163.      _T_h_e _X _W_i_n_d_o_w _S_y_s_t_e_m, DEC Press, Bob Sheifler and Jim Gettys
  164.      _T_h_e _X _W_i_n_d_o_w _S_y_s_t_e_m _T_o_o_l_k_i_t, DEC Press, Paul Asente and Ralph Swick
  165.      _T_h_e _O_S_F/_M_o_t_i_f _P_r_o_g_r_a_m_m_e_r_s _R_e_f_e_r_e_n_c_e, Prentice Hall, OSF
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.